<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Dotnet2-web 后台管理系统</title>
<!--[if lt IE 9]>
<script src="js/html5.js"></script>
<![endif]-->
<%@ include file="/jsp/common/commonJs.jsp"%>
</head>
<body>
	<!--header-->
	<%@ include file="/jsp/top.jsp"%>
	<!--header-->
	<!--aside nav-->
	<%@ include file="/jsp/left.jsp"%>
	<!--aside nav  -->
	<section class="rt_wrap content mCustomScrollbar">
		<div class="rt_content">
			<div class="rt_content">
				<h2>价格列表设置</h2>
				<form method="post" id="form1">
					<section>
						<input type="hidden" name="productId" value="${pf.id}" /> 
						<input type="hidden" name="productName" value="${pf.productName}" />
						<c:forEach items="${fieldVoList}" var="vo" varStatus="status">
							<c:if test="${'select'==vo.fieldType}">
									${vo.fieldName}：
									<select name="${vo.inputName}" class="select">
									<c:forEach items="${vo.fieldPriceList}" var="fp">
										<option
											value="<fmt:formatNumber value="${fp.fieldPrice}" pattern="#"/>">${fp.fieldValue}</option>
									</c:forEach>
								</select>
							</c:if>
							<c:if test="${'radio'==vo.fieldType}">
									${vo.fieldName}：
									<c:forEach items="${vo.fieldPriceList}" var="fp">
									<input type="radio" class="radio" name="${vo.inputName}"
										value="<fmt:formatNumber value="${fp.fieldPrice}" pattern="#"/>" />${fp.fieldValue}
									</c:forEach>
							</c:if>
						</c:forEach>
					</section>
					<section>
						产品价格： <input type="text" name="price" class="textbox textbox_225"
							placeholder="class=225px..." /> <input type="button" value="提交"
							onclick="subForm()" class="group_btn" />
					</section>
				</form>
			</div>
		</div>

		<div class="page_title"></div>
		<table class="table">
			<tr>
				<th>产品名称</th>
				<c:forEach items="${listform}" var="form">
					<th>${form.showName}</th>
				</c:forEach>
				<th>价格</th>
				<th>是否删除</th>
				<th>是否启用</th>
				<th>操作</th>
			</tr>
			<c:forEach items="${list}" var="listmap">
				<tr align="center">
					<c:forEach items="${listmap}" var="map">
						<td><c:if test="${'isDelete'!=map.key && 'isUse'!=map.key && 'id'!=map.key}">
									${map.value}
								</c:if> <c:if test="${map.key=='isDelete'}">
									${map.value=='1'?"<font color=green>是</font>":"<font color=red>否</font>"}
								</c:if> <c:if test="${map.key=='isUse'}">
									${map.value=='1'?"<font color=green>是</font>":"<font color=red>否</font>"}
								</c:if> <c:if test="${'id'==map.key}" >
								<a href="${path}/price/delUpdate.do?id=${map.value}">删除</a>
								<a href="${path}/price/qiyongUpdate.do?id=${map.value}">启用</a>
							</c:if></td>
					</c:forEach>
				</tr>
			</c:forEach>
		</table>
		<aside class="paging">
			<c:forEach items="${page.pageView}" var="page">
				  		${page}
		    </c:forEach>
		</aside>
	</section>
	<!-- 实例化编辑器 -->
	<script type="text/javascript">
		function subForm() {
			var obj = $("#form1");
			//序列化表单
			var radioValue=$("#form1").find("input[type=radio]:checked").val();
			if(undefined==radioValue){
				alert("请先选择单选按钮的值!");
				return;
			}
			var priceValue=$("#form1").find("input[name=price]").val();
			if(''==priceValue){
				alert("请先输入价格!");
				return;
			}
			var jsonuserinfo = obj.serializeObject();
			var field = JSON.stringify(jsonuserinfo); // 产品属性
			var options = {
				url : js.path() + "/price/add.do",
				type : "post",
				dataType : "json",
				//data:{orderNo:orderNo,productField:productField,productPrice:productPrice,paymentType:paymentType,productTime:productTime},
				data : {
					field : field
				},
				success : function(data) {
					if (data.status) {
						alert(data.msg);
						window.location.reload();
					} else {
						alert(data.msg);
						window.location.reload();
					}
				}
			};
			$("#form1").ajaxSubmit(options);
		}
	</script>
</body>
</html>
